import { Component, OnInit } from '@angular/core';
import { ToastController } from '@ionic/angular';
import {Plugins, StatusBarInfoResult} from '@capacitor/core';

const { Device, Navigation, StatusBar } = Plugins;

@Component({
  selector: 'app-index',
  templateUrl: './index.component.html',
  styleUrls: ['./index.component.scss'],
})
export class IndexComponent implements OnInit {

  constructor(public toastController: ToastController) { }

  ngOnInit() {}

  async takePicture() {
    const toast = await this.toastController.create({
      message: '123',
      duration: 2000
    });
    // toast.present();

    const info = await Device.getInfo();
    console.log(info);
    const result: Promise<any> = Navigation.echo({value: 'this message form web'});
    result.then((data) => {
      console.log(data.value);
      StatusBar.getInfo().then((infos: StatusBarInfoResult) => {
          console.log(infos.visible);
          if (infos.visible) {
            StatusBar.hide();
          } else {
            StatusBar.show();
          }
      });
    });
  }

}
